{$CLEO .cs}
{$USE audio}
Alloc($PLAYER_ACTOR, 3)
Alloc($HOWLMP3, 2199)
Alloc($GROWLMP3, 2200)
Alloc($PLAYER_CHAR, 2)
Alloc($ROARMP3, 2202)

script_name 'Monstro'

:Monstro_11
wait 20
if 
  Player.IsPlaying($PLAYER_CHAR)
goto_if_false @Monstro_11
if and
  Char.LocateAnyMeans3D($PLAYER_ACTOR, -510.6371, -2631.101, 163.3544, 700.0, 700.0, 700.0, False)
  Player.IsControlOn($PLAYER_CHAR)
  not Char.IsInAnyCar($PLAYER_ACTOR)
goto_if_false @Monstro_11
0@, 1@, 2@ = Char.GetOffsetInWorldCoords($PLAYER_ACTOR, 0.0, -80.0, 0.0)
set_lvar_int_to_lvar_int 3@ = 0@
set_lvar_int_to_lvar_int 4@ = 1@
0@ -= 30.0
3@ += 30.0
1@ -= 30.0
4@ += 30.0
0@ = Math.RandomFloatInRange(0@, 3@)
1@ = Math.RandomFloatInRange(1@, 4@)
0@, 1@, 2@, 3@ = Path.GetClosestCarNodeWithHeading(0@, 1@, 2@)
Streaming.LoadSpecialCharacter(3, 'Monstro')
Streaming.LoadAllModelsNow

:Monstro_363
wait 0
if 
  Streaming.HasModelLoaded(292)
goto_if_false @Monstro_363
wait 500
6@ = Char.Create(PedType.Mission1, 292, -497.7432, -2635.248, 167.2675)
Char.SetHeading(6@, 3@)
Char.SetHealth(6@, 9000)
Char.SetSuffersCriticalHits(6@, False)
Char.SetDrownsInWater(6@, False)
Char.GiveMeleeAttack(6@, FightStyle.KungFu, 6)
Char.SetDecisionMaker(6@, 32)
Char.SetMoney(6@, 0)
Char.SetUsesUpperbodyDamageAnimsOnly(6@, True)
Char.SetSenseRange(6@, 80.0)
Task.KillCharOnFoot(6@, $PLAYER_ACTOR)
Char.SetAnimGroup(6@, "MAN")
  Char.IsShooting(6@)
Char.SetShootRate(6@, 100)
Char.SetOnlyDamagedByPlayer(6@, True)
Char.SetProofs(6@, False, True, False, True, True)
$cs1_player_car = Char.StoreCarIsInNoSave($PLAYER_ACTOR)
Streaming.MarkModelAsNoLongerNeeded(290)
goto @Monstro_556

:Monstro_556
wait 0
Char.SetAnimSpeed(6@, "SPRINT_PLAYER", 1.7)
if 
  Player.IsPlaying($PLAYER_CHAR)
goto_if_false @Monstro_1204
if 
  not Char.IsDead(6@)
goto_if_false @Monstro_1236
if 
  Char.LocateAnyMeansChar3D($PLAYER_ACTOR, 6@, 700.0, 700.0, 700.0, False)
goto_if_false @Monstro_1204
if 
  Char.IsInAnyCar($PLAYER_ACTOR)
goto_if_false @Monstro_840
if 
  Char.IsSittingInAnyCar($PLAYER_ACTOR)
goto_if_false @Monstro_840
if 
  Char.IsInCar($PLAYER_ACTOR, $cs1_player_car)
goto_if_false @Monstro_840
if 
  Char.LocateOnFootCar2D($PLAYER_ACTOR, $cs1_player_car, 1.0, 1.0, False)
goto_if_false @Monstro_840
if and
  10@ > 0
  not Char.LocateAnyMeansChar3D($PLAYER_ACTOR, 6@, 5.0, 5.0, 5.0, False)
goto_if_false @Monstro_840
if 
  Char.HasBeenDamagedByChar(6@, $PLAYER_ACTOR)
goto_if_false @Monstro_840
if 
  Char.LocateAnyMeansChar3D($PLAYER_ACTOR, 6@, 7.0, 7.0, 7.0, False)
goto_if_false @Monstro_840
goto @Monstro_840

:Monstro_840
wait 0
27@ = Char.GetHeightAboveGround(6@)
14@, 15@, 16@ = Char.GetOffsetInWorldCoords(6@, 0.0, 0.0, 0.0)
17@, 18@, 19@ = Char.GetOffsetInWorldCoords($PLAYER_ACTOR, 0.0, 0.0, 0.0)
28@ = Math.GetDistanceBetweenCoords2D(14@, 15@, 17@, 18@)
sub_float_lvar_from_float_lvar 15@ -= 18@
sub_float_lvar_from_float_lvar 16@ -= 19@
if and
  not Char.IsPlayingAnim(6@, "JUMP_GLIDE")
  15@ > 8.0
  27@ <= 50.0
goto_if_false @Monstro_556
if or
  19@ > 15.0
  28@ > 28.0
goto_if_false @Monstro_556
Task.AimGunAtChar(6@, $PLAYER_ACTOR, 800)
wait 300
Task.PlayAnimNonInterruptable(6@, "JUMP_GLIDE", "PED", 5.0, False, True, True, True, -1)
Char.SetVelocity(6@, 0.0, 0.0, 9.0)
wait 0
21@, 22@, 23@ = Char.GetOffsetInWorldCoords(6@, 0.0, 12.0, 0.0)
24@, 25@, 26@ = Char.GetOffsetInWorldCoords(6@, 0.0, 0.0, 0.0)
sub_float_lvar_from_float_lvar 21@ -= 24@
sub_float_lvar_from_float_lvar 22@ -= 25@
Char.SetVelocity(6@, 21@, 22@, 30.0)
Task.KillCharOnFoot(6@, $PLAYER_ACTOR)
goto @Monstro_556

:Monstro_1204
Char.MarkAsNoLongerNeeded(6@)
AudioStream.Remove($HOWLMP3)
AudioStream.Remove($GROWLMP3)
AudioStream.Remove($ROARMP3)
wait 300
goto @Monstro_11

:Monstro_1236
Char.MarkAsNoLongerNeeded(6@)
wait 500000
return 
